home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.4 Applications 1997 August / SGI IRIX 6.4 Applications 1997 August.iso / dist / mmailp.idb / usr / lib / Zmail / system.zmailrc.z / system.zmailrc
Encoding:
Text File  |  1997-01-22  |  14.0 KB  |  509 lines

  1. # system.zmailrc -- /usr/lib/Zmail/system.zmailrc init file for Z-Mail
  2. # Copyright (c) 1990-94 Z-Code Software, a Division of NCD.
  3.  
  4. # For easier system.zmailrc debugging, set the DBFILE environment
  5. # variable to the name of a file (or tty) that you wish to
  6. # receive debugging output, and use the -debug commandline option
  7. # when you start Z-Mail.
  8.  
  9. # When Z-Mail is run as a mail filter from the .forward file, the
  10. # environment is likely to be that of the MTA, not the user.  The
  11. # Z-Mail variable "home" is forced to be correct, so export it.
  12. setenv HOME $home
  13.  
  14. # Z-Mail and its users should always be able to execute Z-Mail utilities
  15. setenv PATH "${ZMLIB}/bin:${PATH}:/usr/local/bin:/usr/frame/bin"
  16.  
  17. # Set up the display early to allow quick exit in headers-only mode.
  18. # The hdrs_only flag is true if the command line was: "zmail -H".
  19. # The variable summary_fmt is set to change the format of the header
  20. # summaries that are displayed.
  21. if hdrs_only
  22.     set summary_fmt='%22a %M %-2N %T  %.31s'
  23. else
  24.     if is_lite
  25.     set summary_fmt='%22n %M %-2N %5T (%l) %s'
  26.     else
  27.     set summary_fmt='%22n %M %-2N %5T (%l) %.25s'
  28.     endif
  29. endif
  30.  
  31. # Interpret message priorities
  32. # Priority values 1 through 5 are reserved for compatibility with Z-Mail 2.1
  33. # and 3.0, which label those priorities with letters A through E.  "Urgent"
  34. # is recognized on received messages only, by default; X.400 MTAs send it.
  35. priority Urgent=6 High=7 Medium=8 Low=9
  36.  
  37. ##
  38. # If your mail transport agent uses lock files to synchronize with user
  39. # agents, you need to set dot_lock here.  This applies to most mailers
  40. # on System V Unix systems.
  41. ##
  42. # set dot_lock
  43. ##
  44. # The installation procedure should have correctly computed the value of
  45. # the "dot_lock" variable and created $ZMLIB/locking.zmailrc accordingly.
  46. # If you appear to be losing mail or to have trouble with NFS-mounted mail
  47. # delivery areas, check the above setting.
  48. ##
  49. if -e $ZMLIB/locking.zmailrc
  50.     source $ZMLIB/locking.zmailrc
  51. endif
  52.  
  53. ##########################################################################
  54. # Additional customizations for the local system should be added here.   #
  55. # Also check the rest of this file to be sure it is appropriate for your #
  56. # environment.                                                           #
  57. ##########################################################################
  58.  
  59. # The following is a convenient way to load local customizations.
  60. if -e $ZMLIB/custom.zmailrc
  61.     source $ZMLIB/custom.zmailrc
  62. endif
  63.  
  64. ## End local system customizations
  65.  
  66. ## Initialize local natural language support
  67. if $?LANG
  68.     if -e $ZMLIB/locale/$LANG/locale.zmailrc
  69.     source $ZMLIB/locale/$LANG/locale.zmailrc
  70.     else
  71.     source $ZMLIB/locale.zmailrc
  72.     endif
  73. else
  74.     source $ZMLIB/locale.zmailrc
  75. endif
  76.  
  77. ## Stop reading here if displaying headers is our only action
  78. if hdrs_only
  79.     return    # Quits reading this file
  80. endif
  81.  
  82. # This setting usually does no harm and stops problems before they show up.
  83. # Sun's sendmail.cf for diskless workstations is misconfigured to not allow
  84. # commas between addresses.
  85. set picky_mta += "omit_commas, omit_from"
  86.  
  87. ## When reading messages, don't bother looking at lengthy, boring headers.
  88. ignore message-id received via status priority references
  89. ignore resent-message-id return-path return-receipt-to
  90. ignore mime-version content-type content-transfer-encoding
  91. ignore content-length content-lines content-identifier
  92. ignore encoding x-vue-version
  93. ignore x-face
  94.  
  95. # A few extra special-cases -- patterns like this are case-sensitive.
  96. ignore *Error* Content-* X400* Encoding*
  97.  
  98. # Set things up for the "Full headers" toggle in GUI modes
  99. # by ignoring headers that are part of $msg_win_hdr_fmt.
  100. # However, also retain these headers for hardcopy printing
  101. # (see $alwaysignore for more information).
  102. if is_gui
  103.     retain From Date Subject Name Reply-To Resent-[FDTC]* To Cc
  104.     ignore From From* Date Subject Name To Cc    # From* hits "From " line
  105.     set display_headers = unignored
  106. endif
  107. if is_lite
  108.     retain From Date Name Subject Reply-To Resent-[FDTC]* To Cc
  109.     ignore From From* Date Subject Name        # From* hits "From " line
  110.     set display_headers = unignored
  111. endif
  112.  
  113. # Set the print_cmd to mailp by default.
  114. if ! $?print_cmd
  115.   set print_cmd = "$ZMLIB/bin/mailp -c30 -w4 -W80 %O"
  116.   setenv MP_PROLOGUE "$ZMLIB/mp"
  117. endif
  118.  
  119. # By default, zmail's history is set to the last command only.  Set it to
  120. # remember the last 100 commands.
  121. set history = 100
  122.  
  123. # If the variable "unix" is set, then any command that isn't a zmail command
  124. # will execute the command as if you typed it from the shell.  Note, such
  125. # commands will not go through another shell -- this is it.  This may be
  126. # considered confusing for new users, so it is commented out by default.
  127. set unix
  128.  
  129. # Label replies with a header showing the who, what, and when of the
  130. # message being replied-to.
  131. set in_reply_to='%f\n\t"%s" (%d)'
  132.  
  133. # Mail routing and address-fixing conveniences.  If auto_route is set, then
  134. # replies to messages take a closer look at the addresses of the recipients.
  135. # If any redundant paths are present, they are pruned.  Also, the path that
  136. # precedes any hosts listed in the "known_hosts" list is truncated.  This is
  137. # useful for uucp sites only, and is therefore commented out by default.
  138. # set auto_route known_hosts="sun ucbcad well unicom"
  139.  
  140. function resend() {
  141. #% (fallback help text)
  142. #     resend [msg-list] [addresses]
  143. #
  144. # Resend (unedited) the listed messages to the addresses.
  145. #%
  146.     # Versions earlier than 2.1 do not support "mail -resend".
  147.     # Use equivalent backwards-compatible options just in case.
  148.     mail -send -forward $*
  149. }
  150. #   # Below is the Z-Script implementation.  The prompting originally
  151. #   # supported by function resend is now a builtin to "mail -resend".
  152. #
  153. #   shift -m            # Skip the messages specifed or selected.
  154. #   if $status < 0        # If the message list had an error, return.
  155. #    return
  156. #   endif
  157. #   set _msgs = "$output"    # Set _msgs to be result of "shift -m".
  158. #   if "X$_msgs" != X        # If there were messages,
  159. #    msg_list - $_msgs    # Set current message correctly.
  160. #   endif
  161. #   if $argc == 1        # If no other args exist, prompt for user list.
  162. #    ask -i userid "Forward to:"
  163. #    if $status == -1    # If user cancelled command, return now.
  164. #    return
  165. #    endif
  166. #   else
  167. #    set userid = "$*"    # Addresses already specified, get from args.
  168. #   endif
  169. #   mail -resend $_msgs $userid    # Forward messages to userid(s).
  170. #   msg_list $_msgs | unset userid _msgs    # Set $output and unset locals.
  171.  
  172. function saveit() {
  173. #% (fallback help text)
  174. #      saveit [msg-list]
  175. #%
  176.     if "x$_save_file" == "x"
  177.         eval ask -f __save_file -d +/. "$__ask_saving"
  178.     else
  179.         ask -f __save_file -d "$__save_file" "$__ask_saving"
  180.     endif
  181.     if $status == 0
  182.     save $* "$__save_file"
  183.     endif
  184. }
  185.  
  186. function bugreport() {
  187. #% (fallback help text)
  188. # Use this function to send mail to report problems with Z-Mail.
  189. #%
  190.     mail -p bugs        # mail using prepared bugreport form
  191. }
  192. # button -n Gripe bugreport
  193.  
  194. function view_msg() {
  195. #% (fallback help text)
  196. #      view_msg [folder]
  197. #
  198. # This is used to view a single rfc822 message in a file
  199. #%
  200.  
  201.     if $# == 1
  202.     open -T "$1"
  203.     if $status == 0
  204.         pinup ^
  205.     else
  206.         return $status
  207.     endif
  208.     else
  209.     eval error "$__err_takes_one_arg"
  210.     endif
  211.     return 0
  212. }
  213.  
  214. function view_fldr() {
  215. #% (fallback help text)
  216. #      view_fldr [folder]
  217. #
  218. # This is used to view a folder (file of more than one message)
  219. #%
  220.     if $# != 1
  221.     eval error "$__err_takes_one_arg"
  222.     return 0 # Suppress attachment error dialog
  223.     endif
  224.     if $?main_state:(folder_writable)
  225.     ask -m -i __how -d "$__choice_merge" "$__ask_show_folder" \
  226.         "$__choice_create" "$__choice_temp"
  227.     if $status != 0
  228.         return 0
  229.     endif
  230.     else
  231.     ask -m -i __how -d "$__choice_temp" "$__ask_show_folder" \
  232.         "$__choice_create"
  233.     if $status != 0
  234.         return 0
  235.     endif
  236.     endif
  237.     unset __list
  238.     if "$__how" == "$__choice_merge"
  239.     merge "$1" | set __list
  240.     if $status != 0
  241.         return 0
  242.     endif
  243.     else
  244.     open -T "$1" | set __list
  245.     if $status != 0
  246.         return 0
  247.     endif
  248.     if ! $?__list
  249.         close -n "$1"
  250.         return 0
  251.     endif
  252.     if "$__how" == "$__choice_create"
  253.         ask -f __vf_folder "$__ask_folder_write"
  254.         if $status == 0
  255.         copy * $__vf_folder
  256.         unset __list
  257.         open $__vf_folder | set __list
  258.         set __status == $status
  259.         close -n "$1"
  260.         if $__status != 0
  261.             return 0
  262.         endif
  263.         else
  264.         close -n "$1"
  265.         endif
  266.     endif
  267.     ask -l __list -d 1 "$__ask_show_message" $__list 
  268.     if $status == 0
  269.         pinup $__list
  270.     endif
  271.     endif
  272.     return 0
  273. }
  274.  
  275. function page_edit() {
  276. #% (fallback help text)
  277. #      page_edit [filename]
  278. #
  279. # This is used to create a new text file
  280. #%
  281.     sh touch $1
  282.     page -e $1
  283. }
  284.  
  285. # Adjust this default pattern for the local directory server
  286. set __default_lookup_pattern = '.*'
  287.  
  288. function lookup() {
  289.     if ! $?address_book
  290.     error "$__err_no_addrbook"
  291.     return
  292.     endif
  293.     if is_gui
  294.     dialog Browser
  295.     return
  296.     endif
  297.     if is_lite
  298.     dialog Browser
  299.     return
  300.     endif
  301.     if $?1
  302.     __lookup_pattern = "$*"
  303.     else
  304.     __lookup_pattern = "$__default_lookup_pattern"
  305.     endif
  306.     sh $address_book -1 "$__lookup_pattern"
  307. }
  308.  
  309. function window_sh() {
  310. #% (fallback help text)
  311. #      window_sh command args ...
  312. #
  313. # Run an external command, in its own window if appropriate.  Note that
  314. # this forces use of a terminal emulator, even if $window_shell is empty.
  315. #%
  316.     # Use of "$1" "$2" etc. works around unavailability of "$@" for now.
  317.     if is_lite
  318.     builtin screencmd -p builtin sh "$1" "$2" "$3" "$4" "$5" "$6" "$7" \
  319.         "$8" "$9" "$10" "$11" "$12" "$13" "$14" "$15" "$16" "$17" \
  320.         "$18" "$19" "$20" "$21" "$22" "$23" "$24" "$25"
  321.     return $status
  322.     endif
  323.     if is_gui
  324.     if $?window_shell
  325.         set __window_shell = "$window_shell"
  326.     else
  327.         set __window_shell
  328.     endif
  329.     if X"$__window_shell" == X
  330.         set __winterm
  331.         if $?winterm
  332.         if X"$winterm" != X
  333.             set __winterm = "$winterm"
  334.         endif
  335.         endif
  336.         if X"$__winterm" != X
  337.         set __window_shell = "$__winterm -e"
  338.         else
  339.         set __window_shell = "xterm -e"
  340.         endif
  341.     endif
  342.     builtin sh $__window_shell "$1" "$2" "$3" "$4" "$5" "$6" "$7" \
  343.         "$8" "$9" "$10" "$11" "$12" "$13" "$14" "$15" "$16" "$17" \
  344.         "$18" "$19" "$20" "$21" "$22" "$23" "$24" "$25"
  345.     return $status
  346.     endif
  347.     builtin sh "$1" "$2" "$3" "$4" "$5" "$6" "$7" \
  348.     "$8" "$9" "$10" "$11" "$12" "$13" "$14" "$15" "$16" "$17" \
  349.     "$18" "$19" "$20" "$21" "$22" "$23" "$24" "$25"
  350.     return $status
  351. }
  352.  
  353. # This function may used for adding new types automatically.
  354. # Currently, defining this is a security hole in that arbitrary text
  355. # can be executed as Z-Mail commands, with possible bad consequences.
  356. #
  357. # attach -type NewType ":addtype '%s'" None "Commands to create a new type"
  358. #
  359. # function addtype() {
  360. #     # This should be improved to allow ONLY "attach" commands
  361. #     echo "Adding new attachment type ..."
  362. #     source $1
  363. #     sh rm $1
  364. #     attach
  365. # }
  366.  
  367. # Do some tricks with X resources ...
  368. #if is_lite
  369. #    exit    # Exit this script, not the program
  370. #endif
  371. #if is_gui
  372. #    if ! $?XAPPLRESDIR
  373. #    if ! -e /usr/lib/X11/app-defaults/Zmail
  374. #        setenv XAPPLRESDIR $ZMLIB
  375. #    else
  376. #        setenv XAPPLRESDIR /usr/lib/X11/app-defaults
  377. #    endif
  378. #   endif
  379. #   if $?XUSERFILESEARCHPATH
  380. #    if "$XUSERFILESEARCHPATH" !~ "*:$XAPPLRESDIR*"
  381. #        setenv XUSERFILESEARCHPATH "$XAPPLRESDIR/%N:$XUSERFILESEARCHPATH"
  382. #    endif
  383. #   endif
  384. #endif
  385.  
  386. function zmfilter_reply_each () {
  387. #% (fallback help text)
  388. #      zmfilter_reply_each [filename]
  389. #
  390. # This is used to reply to a message using a template file.  The string
  391. # $SUBJECT in the template file is replaced with the message's subject.
  392. #%
  393.     setenv SUBJECT "$[%s]"
  394.     sh "sed 's/"'\$SUBJECT'"/'"'"$SUBJECT"/'" $1 > /tmp/reply$$"
  395.     unsetenv SUBJECT
  396.     if $?autoinclude
  397.         set __need_autoinclude
  398.         unset autoinclude
  399.     endif
  400.     reply -unedited -draft /tmp/reply$$
  401.     if $?__need_autoinclude
  402.         set autoinclude
  403.         unset __need_autoinclude
  404.     endif
  405. }
  406.  
  407. function zmfilter_reply() {
  408.     foreach m $input 'msg_list - $m ; zmfilter_reply_each $1'
  409. }
  410.  
  411. function create_aiff () {
  412. #% (fallback help text)
  413. #      create_aiff [recordaiff arguments]
  414. #
  415. # This function is used to create new audio attachments by recording
  416. # from the microphone.
  417. #%
  418.     sh -m 'Activating microphone' apanel -nodisplay -nofork -source mic
  419.     sh -m 'Recording ... press <Stop> when done.' recordaiff $*
  420.  
  421.     if $?child
  422.     sh kill -INT $child
  423.     endif
  424. }
  425.  
  426. function view_external () {
  427. #% (fallback help text)
  428. #      view_external filename access-type [name [site [direcory [mode [server]]]]]
  429. #
  430. # Display an external-body part.  If the part is external because the
  431. # recipient chose to remove it, present a special-case error message.
  432. #%
  433.     if !$?METAMAIL_PAGER
  434.     if $?PAGER
  435.         if "$PAGER" == more
  436.         setenv METAMAIL_PAGER 'more -w'
  437.         else
  438.         setenv METAMAIL_PAGER "$PAGER"
  439.         endif
  440.     else
  441.         setenv METAMAIL_PAGER 'more -w'
  442.     endif
  443.     endif
  444.         
  445.     if "$2" == "x-removed-by-recipient"
  446.     error "$__err_part_removed"
  447.     return 0
  448.     else
  449.         window_sh "$zmlib/bin/showexternal" "$1" "$2" "$3" "$4" "$5" "$6" "$7"
  450.     return $status
  451.     endif
  452. }
  453.  
  454. function trustable_address() {
  455.     if "$1" !~ "*|*"
  456.     if "$1" !~ "*[     <,][+/~]*"
  457.         return 0
  458.     endif
  459.     endif
  460.     builtin eval builtin error "$__err_suspect_address"
  461. }
  462.  
  463. function trusted_mailto () {
  464. #% (fallback help text)
  465. #    trusted_mailto [ address [ subject [ body [ inperson-reply ] ] ] ]
  466. #%
  467.     builtin mail
  468.     trustable_address "$1"
  469.     if !$status
  470.     builtin compcmd to "$1"
  471.     endif
  472.     builtin compcmd subject "$2"
  473.     if "x$3" != "x"
  474.     builtin compcmd append-text "$3"
  475.     endif
  476.     if "x$4" != "x"
  477.     trustable_address "$4"
  478.     if !$status
  479.         builtin compcmd insert-header X-InPerson-Address: "$4"
  480.     endif
  481.     endif
  482. }
  483.  
  484. function trusted_sendfile () {
  485. #% (fallback help text)
  486. #    trusted_sendfile filename [ address [ subject [ body ] ] ]
  487. #%
  488.     trusted_mailto "$2" "$3" "$4"
  489.     builtin compcmd attach-file "$1"
  490. }
  491.  
  492.  
  493.  
  494. # pick up menu and button definitions
  495. source $ZMLIB/zmail.menus
  496. source $ZMLIB/sgi.func
  497.  
  498. # "cmd" is used to set command line aliases similar to the way "csh"
  499. # does it.  The only difference is that "alias" is a reserved word in
  500. # Z-Mail and Mail, so cmd is used.
  501. #
  502. cmd dq 'd \!*; q'        # Delete a message list, then quit.
  503. cmd unread 'flags \!* U O'    # Mark messages unread.
  504.  
  505. # pick up Lite system initialization
  506. if is_lite
  507.     source $ZMLIB/system.literc
  508. endif
  509.